//
//  ZHClinicModelTool.m
//  Doctor
//
//  Created by liuzhishan on 15/12/23.
//  Copyright © 2015年 shanshan. All rights reserved.
//

#import "ZHClinicModelTool.h"
#import "ZHClinicAllData.h"
#import "DataTool.h"
@implementation ZHClinicModelTool

+(NSMutableArray *)getDateArrayWithResponseObject:(NSDictionary *)responseObject
{
    NSArray *BaseArray  =  [responseObject objectForKey:@"payload"];
    
    NSMutableArray *array = [NSMutableArray arrayWithArray:BaseArray];
    
    
    for (int i = 0;  i < array.count; i ++) {
        
        NSDictionary *dic  = array[i];
        
        ZHClinicAllData *model = [[ZHClinicAllData alloc]init];
        
        [model setValuesForKeysWithDictionary:dic];
        
        long long timeCount = [[dic objectForKey:@"clinicDate"] longLongValue];
        
        model.dateTime = [DataTool getDateWithMS:timeCount];
       
         model.patienterNumber = [[dic objectForKey:@"patienterNumber"] integerValue];
         model.appointmentNumber = [[dic objectForKey:@"appointmentNumber"] integerValue];
         model.notArrive = [[dic objectForKey:@"notArrive"] integerValue];
        
         model.firstVisit = [[dic objectForKey:@"firstVisit"] integerValue];
         model.secondVisit = [[dic objectForKey:@"secondVisit"] integerValue];
        
         model.money = [[dic objectForKey:@"money"] integerValue];
         model.topPrice = [[dic objectForKey:@"topPrice"] integerValue];
        
//        model.appointmentNumber = arc4random() % 20 + 20;
//        model.notArrive = arc4random() % 10 + 10;
//        model.patienterNumber = arc4random() % 20 + 60;
//        
//        model.firstVisit = arc4random() % 50 + 50;
//        model.secondVisit = arc4random() % 40 + 10;
//        
//        model.money = arc4random() % 1000 + 200;
//        model.topPrice = arc4random() % 100 + 100;
        
        
        
        
        
        if (model.patienterNumber == 0)
        {
            model.orangeProportion = 0.0;
            model.pinkProportion = 0.0;
            model.blueProportion = 1.0;
            
        }
        
        else
        {
        model.orangeProportion = (CGFloat)model.appointmentNumber /  (CGFloat)model.patienterNumber  ;
        model.pinkProportion = (CGFloat)model.notArrive/ (CGFloat)model.patienterNumber ;
        model.blueProportion = 1.0 - model.orangeProportion - model.pinkProportion;
            
        }
        
        
        
        
        //nslog(@"lllllll%@",dic);
        
        [array replaceObjectAtIndex:i withObject:model];
        
        
    }
    
   
 
    
    return  array;
}

@end
